//
//  ProductEffect_ViewController.m
//  EggSteward
//
//  Created by 王道林 on 16/9/12.
//  Copyright © 2016年 王道林. All rights reserved.
//

#import "ProductEffect_ViewController.h"
#import "BaseButton.h"
#import "BaseTextField.h"
#import "BaseLabel.h"
#import "Masonry.h"
@interface ProductEffect_ViewController ()
@property (nonatomic, strong) BaseButton *buttonChu;
@property (nonatomic, strong) BaseButton *buttonBig;
@property (nonatomic, strong) BaseButton *buttonEgg;
@property (nonatomic, strong) BaseTextField *textFieldStart;
@property (nonatomic, strong) BaseTextField *textFieldEnd;
@property (nonatomic, strong) BaseTextField *textFieldBatch;
@end

@implementation ProductEffect_ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.navigationItem.title = @"生产效益";
    [self createSubView];
}

-(void)createSubView
{
    _buttonChu = [BaseButton buttonWithType:UIButtonTypeCustom];
    [_buttonChu setImage:[UIImage imageNamed:@"yuchuji_s"] forState:UIControlStateNormal];
    [self.view addSubview:_buttonChu];
    
    _buttonBig = [BaseButton buttonWithType:UIButtonTypeCustom];
    [_buttonBig setImage:[UIImage imageNamed:@"yuchengji"] forState:UIControlStateNormal];
    [self.view addSubview:_buttonBig];
    
    _buttonEgg = [BaseButton buttonWithType:UIButtonTypeCustom];
    [_buttonEgg setImage:[UIImage imageNamed:@"chandanji"] forState:UIControlStateNormal];
    [self.view addSubview:_buttonEgg];
    
    // 布局三个button
    [_buttonChu mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.view.mas_top).mas_offset(10);
        make.left.mas_equalTo(self.view.mas_left).mas_offset(30);
        make.width.mas_equalTo(self.view.mas_width).mas_offset(-20).multipliedBy(0.3333);
        make.height.mas_equalTo(45);
    }];
    [_buttonBig mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.view.mas_top).mas_offset(10);
        make.left.mas_equalTo(_buttonChu.mas_right);
        make.width.mas_equalTo(self.view.mas_width).mas_offset(-20).multipliedBy(0.3333);
        make.height.mas_equalTo(45);
    }];
    [_buttonEgg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.view.mas_top).mas_offset(10);
        make.left.mas_equalTo(_buttonBig.mas_right);
        make.width.mas_equalTo(self.view.mas_width).mas_offset(-20).multipliedBy(0.3333);
        make.height.mas_equalTo(45);
    }];
    // 横线
    UIView *viewLine = [[UIView alloc] init];
    viewLine.backgroundColor = [UIColor grayColor];
    [self.view addSubview:viewLine];
    [viewLine mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(_buttonBig.mas_bottom);
        make.left.mas_equalTo(self.view.mas_left);
        make.right.mas_equalTo(self.view.mas_right);
        make.height.mas_equalTo(1);
    }];

    BaseLabel *lableTime = [[BaseLabel alloc] init];
    lableTime.text = @"时间";
    [self.view addSubview:lableTime];
    
    BaseLabel *labelBatch = [[BaseLabel alloc] init];
    labelBatch.text = @"批次";
    [self.view addSubview:labelBatch];
    
    _textFieldStart = [[BaseTextField alloc] init];
    _textFieldStart.placeholder = @"开始日期";
    _textFieldStart.borderStyle = UITextBorderStyleRoundedRect;
    [self.view addSubview:_textFieldStart];
    
    _textFieldEnd = [[BaseTextField alloc] init];
    _textFieldEnd.borderStyle = UITextBorderStyleRoundedRect;
    _textFieldEnd.placeholder = @"结束日期";
    [self.view addSubview:_textFieldEnd];
    
    _textFieldBatch = [[BaseTextField alloc] init];
    _textFieldBatch.borderStyle = UITextBorderStyleRoundedRect;
    _textFieldBatch.placeholder = @"请选择批次";
    [self.view addSubview:_textFieldBatch];
    
    // 约束
    [lableTime mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(viewLine.mas_bottom).mas_offset(40);
        make.left.mas_equalTo(self.view.mas_left).mas_offset(20);
        make.width.mas_equalTo(40);
        make.height.mas_equalTo(30);
    }];
    
    [_textFieldStart mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(viewLine.mas_bottom).mas_offset(40);
        make.left.mas_equalTo(lableTime.mas_right).mas_offset(25);
        make.width.mas_equalTo(self.view.mas_width).multipliedBy(0.33);
        make.height.mas_equalTo(30);
    }];

    [_textFieldEnd mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(viewLine.mas_bottom).mas_offset(40);
        make.left.mas_equalTo(_textFieldStart.mas_right).mas_offset(15);
        make.width.mas_equalTo(self.view.mas_width).multipliedBy(0.33);
        make.height.mas_equalTo(30);
    }];

    [labelBatch mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(lableTime.mas_bottom).mas_offset(20);
        make.left.mas_equalTo(self.view.mas_left).mas_offset(20);
        make.width.mas_equalTo(40);
        make.height.mas_equalTo(30);
    }];

    [_textFieldBatch mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(lableTime.mas_bottom).mas_offset(20);
        make.left.mas_equalTo(labelBatch.mas_right).mas_offset(25);
        make.right.mas_equalTo(_textFieldEnd.mas_right);
        make.height.mas_equalTo(30);
    }];

    // button
    BaseButton *buttonInquire = [BaseButton buttonWithType:UIButtonTypeSystem];
    [buttonInquire setTitle:@"查询日志" forState:UIControlStateNormal];
    [buttonInquire setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    buttonInquire.backgroundColor = [UIColor colorWithRed:0.157 green:0.651 blue:0.278 alpha:1.000];
    buttonInquire.layer.masksToBounds = YES;
    buttonInquire.layer.cornerRadius = 4;
    [self.view addSubview:buttonInquire];
    
    BaseButton *buttonCurve = [BaseButton buttonWithType:UIButtonTypeSystem];
    [buttonCurve setTitle:@"查询曲线" forState:UIControlStateNormal];
    [buttonCurve setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    buttonCurve.backgroundColor = [UIColor colorWithRed:0.157 green:0.651 blue:0.278 alpha:1.000];
    buttonCurve.layer.masksToBounds = YES;
    buttonCurve.layer.cornerRadius = 4;
    [self.view addSubview:buttonCurve];
    
    BaseButton *buttonEnter = [BaseButton buttonWithType:UIButtonTypeSystem];
    [buttonEnter setTitle:@"录入日志" forState:UIControlStateNormal];
    [buttonEnter setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    buttonEnter.backgroundColor = [UIColor colorWithRed:0.157 green:0.651 blue:0.278 alpha:1.000];
    buttonEnter.layer.masksToBounds = YES;
    buttonEnter.layer.cornerRadius = 4;
    [self.view addSubview:buttonEnter];
    // 约束
    [buttonInquire mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(labelBatch.mas_bottom).mas_offset(10);
        make.left.mas_equalTo(self.view.mas_left).mas_offset(20);
        make.right.mas_equalTo(self.view.mas_right).mas_offset(-20);
        make.height.mas_equalTo(35);
    }];
    
    [buttonCurve mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(buttonInquire.mas_bottom).mas_offset(10);
        make.left.mas_equalTo(self.view.mas_left).mas_offset(20);
        make.right.mas_equalTo(self.view.mas_right).mas_offset(-20);
        make.height.mas_equalTo(35);
    }];
    
    [buttonEnter mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(buttonCurve.mas_bottom).mas_offset(10);
        make.left.mas_equalTo(self.view.mas_left).mas_offset(20);
        make.right.mas_equalTo(self.view.mas_right).mas_offset(-20);
        make.height.mas_equalTo(35);
    }];

    UILabel *lableDorm = [[UILabel alloc] init];
    lableDorm.backgroundColor = [UIColor colorWithWhite:0.659 alpha:1.000];
    lableDorm.text = @"栋舍";
    lableDorm.textAlignment = 1;
    [self.view addSubview:lableDorm];
    
    UILabel *lableDate = [[UILabel alloc] init];
    lableDate.backgroundColor = [UIColor colorWithWhite:0.659 alpha:1.000];
    lableDate.text = @"记录日期";
    lableDate.textAlignment = 1;
    [self.view addSubview:lableDate];

    UILabel *lableCheck = [[UILabel alloc] init];
    lableCheck.backgroundColor = [UIColor colorWithWhite:0.659 alpha:1.000];
    lableCheck.text = @"查看";
    lableCheck.textAlignment = 1;
    [self.view addSubview:lableCheck];
    //约束
    [lableDorm mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(buttonEnter.mas_bottom).mas_offset(30);
        make.left.mas_equalTo(self.view.mas_left).mas_offset(12);
        make.width.mas_equalTo(self.view.mas_width).multipliedBy(0.33333).mas_offset(-8);
        make.height.mas_equalTo(30);
    }];

    [lableDate mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(buttonEnter.mas_bottom).mas_offset(30);
        make.left.mas_equalTo(lableDorm.mas_right).mas_offset(1);
        make.width.mas_equalTo(self.view.mas_width).multipliedBy(0.33333).mas_offset(-8);
        make.height.mas_equalTo(30);
    }];
    
    [lableCheck mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(buttonEnter.mas_bottom).mas_offset(30);
        make.left.mas_equalTo(lableDate.mas_right).mas_offset(1);
        make.width.mas_equalTo(self.view.mas_width).multipliedBy(0.33333).mas_offset(-8);
        make.height.mas_equalTo(30);
    }];

}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
